package com.hqyj.springboot_project01.test.dao;

import com.hqyj.springboot_project01.test.entity.City;
import org.apache.ibatis.annotations.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface CityDao {
    /**
     * 新增
     *
     * @param city
     */
    @Insert("insert into test_city (city_name,local_city_name,country_id,date_created)" +
            "values(#{cityName},#{localCityName},#{countryId},#{dateCreated})")
    @Options(useGeneratedKeys = true, keyColumn = "cityId", keyProperty = "cityId")
    void insertCity(City city);

    @Update("update test_city set city_name=#{cityName}," +
            "local_city_name=#{localCityName} where city_id=#{cityId}")
    void updateCity(City city);

    @Delete("delete from test_city where city_id=#{cityId}")
    void deleteCityById(int cityId);

    @Select("select * from test_city where city_id=#{cityId}")
    City getCityById(int cityId);
}
